#include "wx_pch.h"
#include "SourceDialog.h"
#include <wx/numdlg.h>
#include "defines.h"

#ifndef WX_PRECOMP
	//(*InternalHeadersPCH(SourceDialog)
	#include <wx/intl.h>
	#include <wx/string.h>
	//*)
#endif
//(*InternalHeaders(SourceDialog)
//*)

//(*IdInit(SourceDialog)
const long SourceDialog::ID_STATICTEXT1 = wxNewId();
const long SourceDialog::ID_BUTTON3 = wxNewId();
const long SourceDialog::ID_BUTTON4 = wxNewId();
const long SourceDialog::ID_BUTTON6 = wxNewId();
const long SourceDialog::ID_BUTTON7 = wxNewId();
const long SourceDialog::ID_STATICLINE2 = wxNewId();
const long SourceDialog::ID_STATICTEXT2 = wxNewId();
const long SourceDialog::ID_BUTTON1 = wxNewId();
const long SourceDialog::ID_BUTTON8 = wxNewId();
const long SourceDialog::ID_BUTTON9 = wxNewId();
const long SourceDialog::ID_BUTTON10 = wxNewId();
const long SourceDialog::ID_STATICLINE1 = wxNewId();
const long SourceDialog::ID_BUTTON5 = wxNewId();
const long SourceDialog::ID_BUTTON2 = wxNewId();
const long SourceDialog::ID_TEXTCTRL1 = wxNewId();
const long SourceDialog::ID_BUTTONOPEN = wxNewId();
const long SourceDialog::ID_BUTTONSAVE = wxNewId();
const long SourceDialog::ID_BUTTONSaveAs = wxNewId();
const long SourceDialog::ID_PANEL1 = wxNewId();
//*)

BEGIN_EVENT_TABLE(SourceDialog,wxDialog)
	//(*EventTable(SourceDialog)
	//*)
END_EVENT_TABLE()

SourceDialog::SourceDialog(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
	//(*Initialize(SourceDialog)
	wxBoxSizer* BoxSizer4;
	wxStaticBoxSizer* StaticBoxSizer2;
	wxBoxSizer* BoxSizer2;
	wxBoxSizer* BoxSizer1;
	wxStaticBoxSizer* StaticBoxSizer1;
	wxBoxSizer* BoxSizer3;

	Create(parent, wxID_ANY, _("Source editor"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxMINIMIZE_BOX, _T("wxID_ANY"));
	SetClientSize(wxSize(486,431));
	BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
	Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
	BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
	StaticBoxSizer1 = new wxStaticBoxSizer(wxVERTICAL, Panel1, _("Commands"));
	StaticText1 = new wxStaticText(Panel1, ID_STATICTEXT1, _("Choose from these commands, \nor enter your own code"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
	StaticBoxSizer1->Add(StaticText1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	ButtonMove = new wxButton(Panel1, ID_BUTTON3, _("Move >>"), wxDefaultPosition, wxSize(150,22), 0, wxDefaultValidator, _T("ID_BUTTON3"));
	ButtonMove->SetToolTip(_("move, 0, 0, 0"));
	StaticBoxSizer1->Add(ButtonMove, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	ButtonTurn = new wxButton(Panel1, ID_BUTTON4, _("Turn Clockwise >>"), wxDefaultPosition, wxSize(150,22), 0, wxDefaultValidator, _T("ID_BUTTON4"));
	ButtonTurn->SetToolTip(_("turn, 1, 0, 0"));
	StaticBoxSizer1->Add(ButtonTurn, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	ButtonTurn180 = new wxButton(Panel1, ID_BUTTON6, _("Turn 180 degrees >>"), wxDefaultPosition, wxSize(150,22), 0, wxDefaultValidator, _T("ID_BUTTON6"));
	ButtonTurn180->SetToolTip(_("turn, 2, 0, 0"));
	StaticBoxSizer1->Add(ButtonTurn180, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	ButtonTurnAnti = new wxButton(Panel1, ID_BUTTON7, _("Turn Anti-clockwise >>"), wxDefaultPosition, wxSize(150,22), 0, wxDefaultValidator, _T("ID_BUTTON7"));
	ButtonTurnAnti->SetToolTip(_("turn, -1, 0, 0"));
	StaticBoxSizer1->Add(ButtonTurnAnti, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	StaticLine2 = new wxStaticLine(Panel1, ID_STATICLINE2, wxDefaultPosition, wxSize(150,-1), wxLI_HORIZONTAL, _T("ID_STATICLINE2"));
	StaticBoxSizer1->Add(StaticLine2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	StaticText2 = new wxStaticText(Panel1, ID_STATICTEXT2, _("Advanced commands:"), wxDefaultPosition, wxSize(148,14), 0, _T("ID_STATICTEXT2"));
	StaticBoxSizer1->Add(StaticText2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	Button1 = new wxButton(Panel1, ID_BUTTON1, _("Store x,y,0 >>"), wxDefaultPosition, wxSize(150,22), 0, wxDefaultValidator, _T("ID_BUTTON1"));
	Button1->SetToolTip(_("Store the direct int-value y into memory cell x\nExample: store, 2, 3, 0 stores the value 3 into memory cell 2"));
	StaticBoxSizer1->Add(Button1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	Button2 = new wxButton(Panel1, ID_BUTTON8, _("Add x,y,z >>"), wxDefaultPosition, wxSize(150,22), 0, wxDefaultValidator, _T("ID_BUTTON8"));
	Button2->SetToolTip(_("Add int-value y to the value in memory cell x and store it in memory cell z"));
	StaticBoxSizer1->Add(Button2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	Button3 = new wxButton(Panel1, ID_BUTTON9, _("Ifneq x,y,z >>"), wxDefaultPosition, wxSize(150,22), 0, wxDefaultValidator, _T("ID_BUTTON9"));
	Button3->SetToolTip(_("If int-value of y is not equal to the value in memory cell x, the bot jumps to line z\nExample: ifneq, 1, 2, 4 jumps to line 4 if memory cell 1 does not contain the value 2"));
	StaticBoxSizer1->Add(Button3, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	Button4 = new wxButton(Panel1, ID_BUTTON10, _("Attack x,0,0 >>"), wxDefaultPosition, wxSize(150,22), 0, wxDefaultValidator, _T("ID_BUTTON10"));
	Button4->SetToolTip(_("If x = 1, you attack everyone, if x=0, you attack only bots from other species"));
	StaticBoxSizer1->Add(Button4, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	StaticLine1 = new wxStaticLine(Panel1, ID_STATICLINE1, wxDefaultPosition, wxSize(150,-1), wxLI_HORIZONTAL, _T("ID_STATICLINE1"));
	StaticBoxSizer1->Add(StaticLine1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
	BoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
	ButtonRandom = new wxButton(Panel1, ID_BUTTON5, _("Random"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON5"));
	BoxSizer4->Add(ButtonRandom, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	ButtonReset = new wxButton(Panel1, ID_BUTTON2, _("Reset"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
	BoxSizer4->Add(ButtonReset, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	StaticBoxSizer1->Add(BoxSizer4, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	BoxSizer2->Add(StaticBoxSizer1, 0, wxALL|wxEXPAND|wxALIGN_TOP|wxALIGN_CENTER_HORIZONTAL, 5);
	StaticBoxSizer2 = new wxStaticBoxSizer(wxVERTICAL, Panel1, _("Code"));
	TextCtrl1 = new wxTextCtrl(Panel1, ID_TEXTCTRL1, _("Name_of_bot\n"), wxDefaultPosition, wxSize(203,289), wxTE_AUTO_SCROLL|wxTE_PROCESS_ENTER|wxTE_MULTILINE|wxTE_RICH, wxDefaultValidator, _T("ID_TEXTCTRL1"));
	TextCtrl1->SetToolTip(_("Enter bot source code here"));
	StaticBoxSizer2->Add(TextCtrl1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	BoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
	ButtonOpen = new wxButton(Panel1, ID_BUTTONOPEN, _("Open"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTONOPEN"));
	BoxSizer3->Add(ButtonOpen, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	ButtonSave = new wxButton(Panel1, ID_BUTTONSAVE, _("Save"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTONSAVE"));
	BoxSizer3->Add(ButtonSave, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	ButtonSaveAs = new wxButton(Panel1, ID_BUTTONSaveAs, _("Save as..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTONSaveAs"));
	BoxSizer3->Add(ButtonSaveAs, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	StaticBoxSizer2->Add(BoxSizer3, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
	BoxSizer2->Add(StaticBoxSizer2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	Panel1->SetSizer(BoxSizer2);
	BoxSizer2->Fit(Panel1);
	BoxSizer2->SetSizeHints(Panel1);
	BoxSizer1->Add(Panel1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
	SetSizer(BoxSizer1);
	BoxSizer1->SetSizeHints(this);
	Center();

	Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonMoveClick);
	Connect(ID_BUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonTurnClockClick);
	Connect(ID_BUTTON6,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonTurn180Click);
	Connect(ID_BUTTON7,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonTurnAntiClick);
	Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonStoreClick);
	Connect(ID_BUTTON8,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonAddClick);
	Connect(ID_BUTTON9,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonIfneqClick);
	Connect(ID_BUTTON10,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonAttackClick);
	Connect(ID_BUTTON5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonRandomClick);
	Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonResetClick);
	Connect(ID_BUTTONOPEN,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonLoadClick);
	Connect(ID_BUTTONSAVE,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonSaveClick);
	Connect(ID_BUTTONSaveAs,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SourceDialog::OnButtonSaveAsClick);
	//*)

	min = 0;

}

SourceDialog::~SourceDialog()
{
	//(*Destroy(SourceDialog)
	//*)
}

void SourceDialog::OnButtonMoveClick(wxCommandEvent& event)
{
  Text = TextCtrl1->GetValue();
  TextCtrl1->SetLabel(Text + _("move, 0, 0, 0\r\n") );
}

void SourceDialog::OnButtonTurnClockClick(wxCommandEvent& event)
{
  Text = TextCtrl1->GetValue();
  TextCtrl1->SetLabel(Text + _("turn, 1, 0, 0\r\n") );
}

void SourceDialog::OnButtonTurn180Click(wxCommandEvent& event)
{
  Text = TextCtrl1->GetValue();
  TextCtrl1->SetLabel(Text + _("turn, 2, 0, 0\r\n") );
}

void SourceDialog::OnButtonTurnAntiClick(wxCommandEvent& event)
{
  Text = TextCtrl1->GetValue();
  TextCtrl1->SetLabel(Text + _("turn, -1, 0, 0\r\n") );
}

void SourceDialog::OnButtonRandomClick(wxCommandEvent& event)
{
  srand((unsigned)time(0));
  int random_integer,random_integer2, x, y, z;
  int  highest=10, highest2 = 11;
  rand();
  random_integer = int(highest*(rand()/(RAND_MAX +1.0))) + 1;
  for(int i=0; i<random_integer; i++){
    random_integer2 = int(highest2*(rand()/(RAND_MAX + 1.0))) + 1;
    switch(random_integer2) {
      case 1: Text = TextCtrl1->GetValue();
              TextCtrl1->SetLabel(Text + _("move, 0, 0, 0\r\n") );
              break;
      case 2: Text = TextCtrl1->GetValue();
              TextCtrl1->SetLabel(Text + _("turn, 1, 0, 0\r\n") );
              break;
      case 3: Text = TextCtrl1->GetValue();
              TextCtrl1->SetLabel(Text + _("turn, 2, 0, 0\r\n") );
              break;
      case 4: Text = TextCtrl1->GetValue();
              TextCtrl1->SetLabel(Text + _("move, 0, 0, 0\r\n") );
              break;
      case 5: Text = TextCtrl1->GetValue();
              TextCtrl1->SetLabel(Text + _("turn, -1, 0, 0\r\n") );
              break;
      case 6: Text = TextCtrl1->GetValue();
              x = int(BOT_NUMMEMCELLS*(rand()/(RAND_MAX +1.0)));
              y = int(BOT_NUMMEMCELLS*(rand()/(RAND_MAX +1.0)));
              TextCtrl1->SetLabel(Text + _("store, ") + wxString::Format(_("%d"), x) + _(", ")
                                  + wxString::Format(_("%d"), y) + _(", 0\r\n") );
              break;
      case 7: Text = TextCtrl1->GetValue();
              TextCtrl1->SetLabel(Text + _("move, 0, 0, 0\r\n") );
              break;
      case 8: Text = TextCtrl1->GetValue();
              x = int(BOT_NUMMEMCELLS*(rand()/(RAND_MAX +1.0)));
              y = int(BOT_NUMMEMCELLS*(rand()/(RAND_MAX +1.0)));
              z = int(BOT_NUMMEMCELLS*(rand()/(RAND_MAX +1.0)));
              TextCtrl1->SetLabel(Text + _("add, ") + wxString::Format(_("%d"), x) + _(", ")
                                  + wxString::Format(_("%d"), y) + _(", ") + wxString::Format(_("%d"), z)+ _("\r\n") );
              break;
      case 9:
              x = int(BOT_NUMMEMCELLS*(rand()/(RAND_MAX +1.0)));
              y = int(BOT_NUMMEMCELLS*(rand()/(RAND_MAX +1.0)));
              z = int(BOT_NUMMEMCELLS*(rand()/(RAND_MAX +1.0)));
              Text = TextCtrl1->GetValue();
              TextCtrl1->SetLabel(Text + _("ifneq, ") + wxString::Format(_("%d"), x) + _(", ")
                                  + wxString::Format(_("%d"), y) + _(", ") + wxString::Format(_("%d"), z)+ _("\r\n") );
              break;
      case 10: Text = TextCtrl1->GetValue();
               TextCtrl1->SetLabel(Text + _("move, 0, 0, 0\r\n") );
              break;
      case 11: x = int(2*(rand()/(RAND_MAX +1.0)));
               Text = TextCtrl1->GetValue();
               TextCtrl1->SetLabel(Text + _("attack, ") + wxString::Format(_("%d"), x) + _(", 0, 0\r\n") );
              break;
    }
  }
}

void SourceDialog::OnButtonLoadClick(wxCommandEvent& event)
{
  wxFileDialog *OpenDialog = new wxFileDialog(this, _("Choose a file to open"), wxEmptyString,
                wxEmptyString, _("Genobot files (*.gen)|*.gen"), wxFD_OPEN, wxDefaultPosition);

	if (OpenDialog->ShowModal() == wxID_OK) {
    wxString CurrentDocPath = OpenDialog->GetPath();
    TextCtrl1->LoadFile(CurrentDocPath);
  }
}

void SourceDialog::OnButtonResetClick(wxCommandEvent& event)
{
  TextCtrl1->SetLabel(_("Name_of_bot\r\n"));
}

void SourceDialog::OnButtonSaveClick(wxCommandEvent& event)
{
  TextCtrl1->SaveFile(CurrentDocPath);
}

void SourceDialog::OnButtonSaveAsClick(wxCommandEvent& event)
{
  wxFileDialog *SaveDialog = new wxFileDialog(this, _("Save File As _?"), wxEmptyString,
  wxEmptyString, _("Genobot files (*.gen)|*.gen"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition);

	if (SaveDialog->ShowModal() == wxID_OK) {
		CurrentDocPath = SaveDialog->GetPath();
		TextCtrl1->SaveFile(CurrentDocPath);
	}
}


void SourceDialog::OnButtonStoreClick(wxCommandEvent& event)
{
  const wxString caption = _("Set Parameters");
  const wxString valuePrompt = _("Value:");
  const wxString memcellPrompt = _("Memory Cell:");
  const wxString memcellMessage = _("Which memory cell?");
  memcell = wxGetNumberFromUser( memcellMessage, memcellPrompt, caption, 0, min, BOT_NUMMEMCELLS - 1, NULL, wxDefaultPosition);

  if(memcell>-1) {
    const wxString valueMessage = _("What value to be stored?");
    value = wxGetNumberFromUser( valueMessage, valuePrompt, caption, 0, min, 1000, NULL, wxDefaultPosition);
    if(value>-1) {
      Text = TextCtrl1->GetValue();
      TextCtrl1->SetLabel(Text + _("store, ") + wxString::Format(_("%d"), memcell) + _(", ") + wxString::Format(_("%d"), value) + _(", 0\r\n") );
    }
  }
}

void SourceDialog::OnButtonAddClick(wxCommandEvent& event)
{
  const wxString caption = _("Set Parameters");

  const wxString valueMessage = _("Add what value?");
  const wxString valuePrompt = _("Value:");
  value = wxGetNumberFromUser( valueMessage, valuePrompt, caption, 0, min, 1000, NULL, wxDefaultPosition);

  if(value>-1) {
    const wxString memcellMessage = _("To which memory cell?");
    const wxString memcellPrompt = _("Memory Cell:");
    memcell = wxGetNumberFromUser( memcellMessage, memcellPrompt, caption, 0, min, BOT_NUMMEMCELLS - 1, NULL, wxDefaultPosition);

    if(memcell>-1) {
      const wxString memcellMessage2 = _("Store in which memory cell?");
      memcell2 = wxGetNumberFromUser( memcellMessage2, memcellPrompt, caption, 0, min, BOT_NUMMEMCELLS - 1, NULL, wxDefaultPosition);

      if(memcell2>-1) {
        Text = TextCtrl1->GetValue();
        TextCtrl1->SetLabel(Text + _("add, ") + wxString::Format(_("%d"), memcell) + _(", ") + wxString::Format(_("%d"), value)
                            + _(", ") + wxString::Format(_("%d"), memcell2) + _("\r\n") );
      }
    }
  }
}

void SourceDialog::OnButtonIfneqClick(wxCommandEvent& event)
{
  const wxString caption = _("Set Parameters");

  const wxString valueMessage = _("If what value?");
  const wxString valuePrompt = _("Value:");
  value = wxGetNumberFromUser( valueMessage, valuePrompt, caption, 0, min, BOT_NUMMEMCELLS - 1, NULL, wxDefaultPosition);

  if(value>-1) {
    const wxString memcellMessage = _("is not the same as which memory cell?");
    const wxString memcellPrompt = _("Memory Cell:");
    memcell = wxGetNumberFromUser( memcellMessage, memcellPrompt, caption, 0, min, BOT_NUMMEMCELLS - 1, NULL, wxDefaultPosition);

    if(memcell>-1) {
      const wxString lineMessage = _("Goto which line?");
      const wxString linePrompt = _("Line no.:");
      line = wxGetNumberFromUser( lineMessage, linePrompt, caption, 0, min, 50, NULL, wxDefaultPosition);

      if(line>-1) {
        Text = TextCtrl1->GetValue();
        TextCtrl1->SetLabel(Text + _("ifneq, ") + wxString::Format(_("%d"), memcell) + _(", ") + wxString::Format(_("%d"), value)
                            + _(", ") + wxString::Format(_("%d"), line) + _("\r\n") );
      }
    }
  }
}

void SourceDialog::OnButtonAttackClick(wxCommandEvent& event)
{
  const wxString caption = _("Set Parameters");
  const wxString attackPrompt = _("Attack:");
  const wxString attackMessage = _("Set to 1 to attack everyone. Set to 0 to attack only bots from other species");
  memcell = wxGetNumberFromUser( attackMessage, attackPrompt, caption, 0, min, 1, NULL, wxDefaultPosition);

  if(memcell>-1) {
      Text = TextCtrl1->GetValue();
      TextCtrl1->SetLabel(Text + _("attack, ") + wxString::Format(_("%d"), memcell) +  _(",0, 0\r\n") );
  }
}
